
<!-- 头部 start -->
<div class="header w1210 bc mt15">
    <script>
        $(function(){
            $("#input_keyword").focus(function(){
                $(this).addClass('search-focus');
                $(document).keydown(function(event){
                    if(event.keyCode==13){
                        if($(".search-focus").val()){
                            window.location.href=window.location.protocol+'//'+window.location.host+'/list.html?'+'keyword='+$('#input_keyword').val();
                        }
                    }
                });
            });
            $("#input_keyword").blur(function(){
                $(this).removeClass('search-focus');
            });
        });
    </script>
    <div class="classify-block">
        <div class="classify">
            <ul class="list-unstyled all-goods-type clearfix" style="height: 40px">
                <li class="pull-left all-categories" style="height: 40px">
                    <span class="text-left">全部商品分类</span>
                    <img src="__PUBLIC__/template/images/fenlei_icon.png" alt="" class="pull-right">
                    <ul class="list-unstyled all-categories-detail">
                        <?php foreach($catData as $k => $v):?>
                        <li class="fl-hover">
                            <h4>
                                <a href="https://www.myzte.com/list.html?cat_id=1">{$v.cate_name}</a>
                            </h4>
                            <div class="more-goods-block clearfix fl-one">
                                <div class="goods-block">
                                    <ul class="list-unstyled clearfix">
                                        <?php foreach($v['children'] as $k1 => $v1):?>
                                        <li class="pull-left goods-deatil-li">
                                            <div class="goods-image">
                                                <?php echo showImage($sm_logo[0]);?>
                                            </div>
                                            <div class="goods-name">
                                                <a href="<?php echo U('Search/cat_search?cat_id='.$v1['id'],'',FALSE)?>"><span><?php echo $v1['cate_name']?></span></a>
                                            </div>
                                        </li>
                                        <?php endforeach;?>
                                    </ul>
                                </div>
                                <div class="recommend-goods hide">
                                    <div class="recommend-goods-block">
                                        <a href="https://www.myzte.com/cart-blank.html">
                                            <img src="__PUBLIC__/template/images/goods1.png" alt="">
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <?php endforeach;?>
                        <textarea id="first" class="hide">
</textarea>
                        <script>
                            $(function(){
                                /**
                                 * 模板填充工具
                                 */
                                var substitute = function(str, obj) {
                                    return str.replace(/\\?\{([^{}]+)\}/g, function(match, name) {
                                        if (match.charAt(0) == '\\') return match.slice(1);
                                        if(name.match(/\./)){
                                            value = eval('obj.'+name);
                                            return value?value:'';
                                        }
                                        return (obj[name] != undefined) ? obj[name] : '';
                                    });
                                };

                                $('.all-categories-detail .fl-hover').each(function(){
                                    var secondcate_len = $(this).find('.goods-deatil-li').length;
                                    if(secondcate_len>=11){
                                        $(this).find('.goods-deatil-li:nth-child(n+10)').hide();
                                        $(this).find('.goods-look-all').show();
                                    }
                                })
                            })
                        </script>
                    </ul>
                </li>
                <li class="pull-left">
                    <a href="https://www.myzte.com/index.html">首页</a>
                </li><li class="pull-left create-fl">
                <a href="https://www.myzte.com/v8.html">Blade V8</a>
                <s style="position: absolute;top: -10px;line-height: 1.2;"><img src="__PUBLIC__/template/images/new.png" alt="new"></s>

            </li>

                <li class="pull-left create-fl">
                    <a href="https://www.myzte.com/6902176008580.html">天机7 MAX</a>
                    <s style="position: absolute;top: -10px;line-height: 1.2;"><img src="__PUBLIC__/template/images/hot.png" alt="hot"></s>

                </li>

                <li class="pull-left create-fl">
                    <a href="https://www.myzte.com/6902176000645.html">天机7</a>
                    <s style="position: absolute;top: -10px;line-height: 1.2;"><img src="__PUBLIC__/template/images/hot.png" alt="hot"></s>
                </li>

                <li class="pull-left create-fl"><a href="https://www.myzte.com/6902176003141.html">Blade系列</a>
                    <div class="fenlei-detail-block">
                        <div class="fenlei-detail">
                            <ul class="list-unstyled fenlei-two clearfix">
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/6902176003141.html" target="_blank">
                                        <div class="goods-img" style="border-left: none;">
                                            <img src="__PUBLIC__/template/images/33a4865f7219.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>Blade A2</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span class="new-pri">￥<strong>669.0</strong></span>

                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/6902176009532.html" target="_blank">
                                        <div class="goods-img">
                                            <img src="__PUBLIC__/template/images/243509c98820.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>Blade A2 Plus</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span class="new-pri">￥<strong>869.0</strong></span>

                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/v8.html" target="_blank">
                                        <div class="goods-img">
                                            <img src="__PUBLIC__/template/images/7bb917a907a0.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>Blade V8</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span class="new-pri">￥<strong>1469.0</strong></span>

                                            </div>
                                        </div>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>

                </li>
                <li class="pull-left create-fl" id="cate-jxpj">
                    <a href="https://www.myzte.com/list.html?cat_id=2">ZTE精品系列</a>


                    <div class="fenlei-detail-block">
                        <div class="fenlei-detail">
                            <ul class="list-unstyled fenlei-two clearfix">
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/6902176002823.html" target="_blank">
                                        <div class="goods-img" style="border-left: none;">
                                            <img src="__PUBLIC__/template/images/116bc2b6c266.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>中兴 V7 MAX(全网通)</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span>￥<strong>1799.0</strong></span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/6902176002793.html" target="_blank">
                                        <div class="goods-img">
                                            <img src="__PUBLIC__/template/images/1fbc59cd878f.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>中兴 A910</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span>￥<strong>1299.0</strong></span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <li class="pull-left">
                                    <a href="https://www.myzte.com/6934933095359.html" target="_blank">
                                        <div class="goods-img">
                                            <img src="__PUBLIC__/template/images/8652332ef46a.jpg!s" alt="">
                                        </div>
                                        <div class="goods-data">
                                            <div class="goods-name-block">
                                                <span>中兴 Spro 2 LTE 智能微投</span>
                                            </div>
                                            <div class="goods-pri-block">
                                                <span>￥<strong>4699.0</strong></span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </li>

                <li class="pull-left crceate-fl"><a href="http://www.myzte.cn/">中兴社区</a></li>
                <li class="pull-right news-li">
                    <div class="news-block clearfix">
                        <div id="newsBox">
                            <ul><li><a href="https://www.myzte.com/p-97.html">【公告】ZTE中兴 Blade V8预约活动开奖！</a></li><li><a href="https://www.myzte.com/p-96.html">春节期间发货时间调整公告</a></li><li><a href="https://www.myzte.com/p-92.html">关于中兴手机商城12月28日系统升级公告</a></li></ul>

                            <ul><li><a href="https://www.myzte.com/p-97.html">【公告】ZTE中兴 Blade V8预约活动开奖！</a></li><li><a href="https://www.myzte.com/p-96.html">春节期间发货时间调整公告</a></li><li><a href="https://www.myzte.com/p-92.html">关于中兴手机商城12月28日系统升级公告</a></li></ul>
                        </div>
                        <div class="news-name"><img src="__PUBLIC__/template/images/horn.png" alt=""></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<script>
    <?php $ic=C('IMAGE_CONFIG');?>
    var picView ="<?php echo $ic['viewPath']?>";
    $("#cart_list").mouseover(function () {
        $.ajax({
            type:'GET',
            url:"<?php echo U('Cart/ajaxCartList')?>",
            dataType:'json',
            success:function (data) {
                var a = 0;
                html ="<ul class='list-unstyled'>";
                $(data).each(function (k,v) {
                    html +='<li class="clearfix shopcart-goods-li" id="cart" value="'+v.goods_id+ '-'+v.goods_attr_id+'"><div style="float: left;" class="shopcart-goods-image">' +
                            '<img width="50" src="'+picView+v.mid_logo+'" /> ' +
                            '</div>';
                    html +='<div style="float: left;" class="shopcart-goods-name">' +
                            '<p>'+ v.goods_name+'</p>' +
                            '</div>';
                    html +='<div style="float: left;margin-left: 20px;" class="shopcart-goods-price">' +
                            '<div style="float: left";> ￥'+v.price+'</div>' +
                            '<div style="float: left";>' +
                        '<a info-data="' + v.goods_id + '-' + v.goods_attr_id + '" onclick="delCart( this )" href="javascript:void(0); ">删除</a>'+
                            '</div></div></li>';
                    a++

                });
                html +="</ul>";
                if(a>0){
                    $('#cart_div_list').html(html);
                }else{
                    $('#cart_div_list').css('display','block');
                }

            }
        });
    });
    //var count =0;
    $(function () {
         /*count = $('.list-unstyled').children.length;
        if(count > 0){
            $('#count').removeClass('hidden').html(count);
        }*/
        $.ajax({
            type:'GET',
            url:"<?php echo U('Cart/ajaxCartList')?>",
            dataType:'json',
            success:function (data) {
                var i = 0;
                $(data).each(function (k,v) {
                    i++;
                });
                if(i>0){
                    $('#count').removeClass('hidden').html(i);
                }
            }
        });
    });
    function delCart( a ){
        var info = $(a).attr('info-data');
        $.ajax({
            type:'GET',
            url:"{:U('Cart/ajaxDelCart')}",
            data:"id="+info,
            dataType:'json',
            success:function (data) {
                if(data.code==1){
                    $("li[value='+ info +']").remove();
                }
            }
        });
    }
    //购物车数量加载
    var cart_count=null;
    var cart_count_get=false;
    $.get("<?php echo U('Cart/ajaxDelCart')?>")
        .done(function(re){
            if(re.data&&re.data.count>0){
                $('.cart-count').removeClass('hidden').text(re.data.count);
                cart_count=re.data.count;
                $('.shop-cart').find('.shopcart-null').remove();
            }else{
                $('.shop-cart').find('.shopcart-full').remove();
            }
        })
        .fail(function(){
            $('.shop-cart').find('.shopcart-full').remove();
        })
        .always(function(){
            cart_count_get=true;
        })
    //购物车项
    var cart_load_twice=0;
    $('.shop-cart').on('mouseenter',function(e){
        if(cart_count_get){
            if(cart_count){
                if(cart_load_twice===0){
                    cart_load_twice=1;
                    $.ajax({
                        url:'https://www.myzte.com/index.php/openapi/cart/preview',
                        dataType:'json'
                    })
                        .done(function(re){
                            if(re.data && re.data.length){
                                var item_html ='',item_html_tpl = $('#minicart_item_tpl').html();
                                $.each(re.data,function(idx,item){
                                    item_html+=substitute(item_html_tpl,item);
                                });
                                $('.shopcart-full').show().find('ul').html(item_html);
                                $('.shop-cart').find('.shopcart-logo').addClass('active');
                            }
                        });
                }else{
                    $(this).find('.shopcart-logo').addClass('active');
                    $('.cart-content').show();
                }
            }else{
                $(this).find('.shopcart-logo').addClass('active');
                $('.cart-content').show();
            }
        }
    });
    $('.shop-cart').on('mouseleave',function(){
        $('.cart-content').hide();
        $(this).find('.shopcart-logo').removeClass('active');
    });
</script>